<%@ page contentType="text/html; charset=UTF-8" buffer="16kb"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragrma", "no-cache");
    response.setDateHeader("Expires", 0);
    Long resid = Long.parseLong(request.getParameter("id"));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>linux综合性能页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<%@ include file="../include/common.jsp"%>
<%@ include file="../include/table.jsp"%>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/progressbar/jquery.progressbar.min.js"></script>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/perf/listPage.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>

<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.jqueryplugin.js"></script>
	
<script type="text/javascript">

	
	function initErrpt(){
		$.ajax({
			type:'post',
			url:'real-time!getListFromCache.action',
			data:{
				resId:<%=resid %>,
				childType:'1202060100000',
				propIds:'120206010000002,120206010000001'
			},
			cache:false,
			dataType:'json',
			success:function(data){
				$('#invalidSessionList > thead > tr').append('<th width="20%">采集时间</th>');
				$('#invalidSessionList > thead > tr').append('<th width="20%">资源名称</th>');
				$.each(data.cols,function(index,value){
						$('#invalidSessionList > thead > tr').append('<th>'+value.name+' (MB)</th>');
				});
				
				var tbl = $('#invalidSessionList > tbody ');
				$.each(data.data,function(index,value){
				    var dataHtml = (index%2)==0?'<tr class="odd" >': '<tr class="even" >';
				    $.each(value,function(i,v){
				    	dataHtml +='<td>'+v+'</td>';
				    });
				    dataHtml +='</tr>';
					tbl.append(dataHtml);
				});
			}
		});
	}
	
	var tcpChart;
	var swapChart;
	var processChart
	var invalidChart
	function initTCP() {
			tcpChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","tcpChart1", "100%", "100%", "0", "1" );
			swapChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","swapChart11", "100%", "100%", "0", "1" );
			processChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","processChart11", "100%", "100%", "0", "1" );
			invalidChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","invalidChart22", "100%", "100%", "0", "1" );
		
		//吞吐
		$.ajax({
			url : 'real-time!get2LineChart.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>, 
				childType:'1202060500000',
				propIds:'120206050000001,120206050000002'
			},
			success : function(data) {
				tcpChart.setJSONData(data);
				tcpChart.render("throughputDiv");
			}
		});

	}
	
	
	var uptimeColChart;
	var fsColChartc;
	function initBaseInfo(){
			//基本信息
			$.ajax({
				url : 'real-time!getBaseInfo.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					propIds:'attr_110200000000001,prop_110206000000001,prop_110206000000006,prop_110206000000004,prop_110206000000005,prop_110200000000002,prop_110200000000001'
				},
				success : function(data) {
					$('#attr_110200000000001').text(data.attr_110200000000001); //实例名
					$('#prop_110206000000001').attr('title',data.prop_110206000000001).text(data.prop_110206000000001)//
					$('#prop_110206000000006').text(data.prop_110206000000006); //字符集
					$('#prop_110206000000004').text(data.prop_110206000000004); //创建时间
					$('#prop_110206000000005').text(data.prop_110206000000005); //启动时间
					$('#prop_110200000000002').text(data.prop_110200000000002); //响应时间
					$('#prop_110200000000001').text(data.prop_110200000000001); //状态
					$('#resIp').text(data.ip);
				}
			});
			
			//SGA信息
			$.ajax({
				url : 'real-time!getBaseInfo.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1202060300000',
					propIds:'prop_120206030000001,prop_120206030000002'
				},
				success : function(data) {
					$('#prop_120206030000001').progressBar(data.prop_120206030000001,{ showText: true, barImage: '${pageContext.request.contextPath}/style/default/bsm/images/progressbg_yellow.gif'}); 
					$('#prop_120206030000002').progressBar(data.prop_120206030000002,{ showText: true, barImage: '${pageContext.request.contextPath}/style/default/bsm/images/progressbg_yellow.gif'}); 
				}
			});
			
			//PGA 
			$.ajax({
				url : 'real-time!get2LineChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1202060500000',
					propIds:'120206050000001,120206050000002'
				},
				success : function(data) {
					if(typeof uptimeColChart == undefined || uptimeColChart == null){
						uptimeColChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","tcpChart1", "100%", "130", "0", "1" );
					}
					uptimeColChart.setJSONData(data);
					uptimeColChart.render("pgaColChart");
				}
			});
			
			//表空间
			if(typeof fsColChartc == undefined || fsColChartc == null){
				fsColChartc =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","fsColChart11", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1202060100000',
					propIds:'120206010000003',
					top:'15',
					unit:'%'
				},
				success : function(data) {
					fsColChartc.setJSONData(data);
					fsColChartc.render("fsColChart");
				}
			});
	}
	
	$(document).ready(function() {
			initBaseInfo();
			initTCP();
			initErrpt();
		setInterval('initBaseInfo()',60000);
	});
</script>

</head>
<body>

	<div class="column">
		<div class="col-main">
			<!--基本信息-->
			<div class="col-l-extra h-400">
			<h2 class="title-h2 m-0">基本信息</h2>
			<ul class="col-l-ul">
					<li><span class="col-l-ul-l" >数据库类别:</span><span 
								class="col-l-ul-r"><img src="${pageContext.request.contextPath}/style/default/bsm/perf/images/informix24_24.png"></img></span>
					</li>
					<li><span class="col-l-ul-l" >IP:</span><span id="resIp"
							class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >实例名:</span><span id="attr_110200000000001"
								class="col-l-ul-r"></span>
					</li>		
					<li><span class="col-l-ul-l" >版本:</span><span id="prop_110206000000001"
								class="col-l-ul-r col-l-ul-r-textell" style="width:70%;"></span>
					</li>			
					<li><span class="col-l-ul-l" >页大小:</span><span id="prop_110206000000006"
								class="col-l-ul-r"></span>
					</li>			
					<li><span class="col-l-ul-l" >常驻内存大小:</span><span id="prop_110206000000004"
							class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >虚拟内存初始化大小:</span><span id="prop_110206000000005"
								class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >响应时间(ms):</span><span id="prop_110200000000002"
								class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" >连接状态:</span><span id="prop_110200000000001"
								class="col-l-ul-r"></span>
					</li>
			   </ul>
			</div>
			<!--@end基本信息-->
			<div class="col-r-main">
				<div class="col-v-rate-extra" >
				  <h2 class="title-h2 m-0">事务 [当天趋势图]-[事务提交速率,事务回滚速率]</h2>
				  <div id="pgaColChart"></div>
				</div>
				<!--@end基本信息-->
				<div class="col-v-rate-extra f-r">
				<h2 class="title-h2 m-0">排序率</h2>
					  	<ul class="col-l-ul">
							<li><span class="col-l-ul-l" style="width:60%;text-align:left;">内存排序率：</span><span
								style="float:left" id="prop_120206030000001"></span>
							</li>
							<li><span class="col-l-ul-l" style="width:60%;text-align:left;">磁盘排序率：</span><span
								style="float:left" id="prop_120206030000002"></span>
							</li>
					   </ul>
			    </div>
			     <div class="col-v-rate-extra" style="width:99%">
		            <h2 class="title-h2 m-0">数据库使用率 TOP15</h2>
			       <div id="fsColChart"></div>
			    </div>
		 </div>
	  </div>
	</div>
	
       <div class="column b-1">
					<h2 class="title-h2 m-0">数据库空间分配详细列表-[分配空间,已用空间]</h2>
				   <table width='100%' cellpadding='0' cellspacing='0' border='0' class='display' id='invalidSessionList'>
				       <thead>
				             <tr>
				             </tr>
				       </thead>
				       <tbody>
				       </tbody>
				   </table>
			</div>
	 
	<div class="column" style="width:100px; height:5px;"></div>
</body>

</html>